import axios from 'axios'
//引入进度条（必须引入nprogress.css的样式）
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
const instance = axios.create({
    baseURL: "/api", //接口地址仅供参考
    timeout: 5000
})

instance.interceptors.request.use((config)=>{
    Nprogress.start()
    return config;
},err =>{
    Nprogress.done()
    return Promise.reject(err);
})

instance.interceptors.response.use((res)=>{
    Nprogress.done()
    console.log(res.data);
    return res.data;
},err=>{
    Nprogress.done()
    return Promise.reject(err)
})

export default instance